<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
$ui = new UI();
$tpl = new Template2();
$tpl->load( array( "news" => "news.htm" ) );
$conf = new Config();
$news = $conf->Get( "news" );
$tpl->set( "newsmessage", $news );
$tpl->show( "news" );
if ( $conf->get( "calcbet" ) == 1 )
{
    $ui->showErrorPage( "<p class=error>颁奖过帐中，请稍後再使用本功能！</p>" );
    exit();
}
$dt = getvar( "dt" );
$lotto_id = intval( getvar( "lotto_id" ) );
if ( $lotto_id == 0 )
{
    exit( "Hack!" );
}
$lotto = new lotto( $lotto_id );
$paperShowOpen = getPaperMinDate( 0 - 1 );
if ( strtotime( $lotto->data['open'] ) < strtotime( $paperShowOpen ) )
{
    $ui->showErrorPage( "只可查询{$paperShowOpen}之後的帐" );
}
echo "<br><p style=\"width:640px; cursor:none; font-weight:normal;\" class=\"headtitle colorBtn01 bgImg_0 clrBrd_0\"><span style=\"padding:8px 0px 5px 8px;\" class=head1>".L_HISTORY." ".$lotto->data['open']."</span>"."<span style=\"padding:7px 8px 5px 0px;\" class=head2><a href=\"javascript:window.print()\">列印</a>&nbsp;|&nbsp;<a href=\"javascript:history.go(-1)\">回上一页</a></span></p>";
$cache_lotto = array();
$total = 0;
$result = 0;
$count = 0;
$totalback = 0;
$rs = getdb( "select * from bet where lotto_id=".$lotto_id." and user_id=".$_SESSION['uid']." order by createtime desc" );
if ( !$rs->eof )
{
    echo "<table width=640 class=\"tblMy3D\">";
    echo "<tr class=\"headtitle bgImg_0 clrBrd_0\"><td>下注时间<td>下注期数";
    echo "<td>下注内容</td><td>盘类</td><td>赔率</td><td align=right>下注金额";
    echo "<td align=right>退水<td align=right nowrap>结果<td>备注";
    while ( !$rs->eof )
    {
        echo "<tr valign=top class=td2>";
        echo "<td nowrap>".date( "m-d H:i:s", $rs->f['createtime'] )."</td>";
        if ( !isset( $cache_lotto[$rs->f['lotto_id']] ) )
        {
            $cache_lotto[$rs->f['lotto_id']] = getdb( "select round,spec,open from lotto where id=".$rs->f['lotto_id'] );
        }
        $rs1 = $cache_lotto[$rs->f['lotto_id']];
        echo "<td nowrap>".d3( $rs1->f['round'] )." 期 ".$rs1->f['open']."</td>";
        echo "<td>".GetBetContent( $rs->f['bettype'], $rs->f['numbers'], $rs->f['amount'] )."</td>";
        echo "<td>".$g_disk_name[$rs->f['disk']]."</td>";
        echo "<td align=right>".show_rate( $rs->f['bettype'], $rs->f['rate'] )."</td>";
        echo "<td align=right>".$rs->f['amount']."</td>";
        echo "<td align=right>".$rs->f['a1']."</td>";
        echo "<td align=right>".say_numbercolor( $rs->f['b1'], 3 )."</td>";
        $reme = "";
        if ( $rs->f['rame'] == 1 )
        {
            $reme = "<font color='red'>逾时</font>";
        }
        if ( $rs->f['rame'] == 2 )
        {
            $reme = "<font color='red'>取消</font>";
        }
        if ( $rs->f['rame'] == 3 )
        {
            $reme = "<font color='red'>异常</font>";
        }
        if ( $rs->f['rame'] == 4 )
        {
            $reme = "<font color='red'>特连</font>";
        }
        if ( chkBet_peace( $rs->f ) )
        {
            $reme = "<font color='blue'>和局</font>";
        }
        echo "<td nowrap>".$reme."</td>";
        echo "</tr>";
        $total += $rs->f['amount'];
        ++$count;
        if ( $reme == "" )
        {
            $result += $rs->f['b1'];
            $totalback += $rs->f['a1'];
        }
        $rs->movenext();
    }
    echo "<tr class=\"headtitle bgImg_0 clrBrd_0\"><td colspan=5 align=right>合计 ".$count." 笔</td><td align=right>".$total."</td><td align=right nowrap>".sprintf( "%.2f", $totalback )."</td><td align=right nowrap>".sprintf( "%.2f", $result )."</td><td nowrap> </td></tr>";
    echo "</table><br>";
}
$ui->footer();
echo "\r\n\r\n";
?>